<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <input type="button" value="新增" @click="add">
        <input type="text" v-model="keyword" placeholder="请输入关键字">
        <table>
            <tr v-for="(temp,index) in list">
                <td>
                    {{temp.id}}
                </td>
                <td>
                    {{temp.title}}
                </td>
                <td>
                    {{temp.imports}}
                </td>
                <td>
                    {{temp.text}}
                </td>
                <td>
                    {{temp.cat}}
                </td>
                <td>
                    {{temp.atou}}
                </td>
                <td>
                    {{temp.time}}
                </td>
            </tr>
        </table>
    </div>


    <script src="./vue.js"></script>
    <script src="./jquery-3.6.0.min.js"></script>

    <script>
        let baseUrl = 'http://localhost:8000/blog'
        new Vue({
            el: '#app',
            data: {
                list: [],
                keyword:''
            },

            watch:{
                keyword(){
                    this.ajax_home('get',{"body":this.keyword})   
                }
            },
            methods: {
                ajax_home(method,obj) {
                    $.ajax({
                        url: baseUrl,
                        method: method,
                        data: obj,
                        success:(res)=>{
                            this.list = res
                        }
                    });
                },
                query(){},
                add(){
                    
                    console.log(this.keyword);
                }
            },
            created: function () {           
                this.ajax_home('get','')
            }

        })

        
    </script>
</body>

</html>